/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.ipti.br.tag.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import org.ipti.br.tag.util.EncryptionUtil;

/**
 *
 * @author israel
 */
@Entity
public class Nationality extends AbstractEntity{

    @Column(length = 2, nullable = false, unique=true)
    private String iso;
    
    @Column(length = 45, nullable = false)
    private String name;
    
    @Column(length = 45, nullable = false)
    private String patronym;
    
    @Column(length = 3, nullable = false, unique=true)
    private String iso3;
    
    @Column(name="numcode", nullable = true)
    private int numCode;
    
    public Nationality() {
    }

    @Override
    public void generateHash(){
        if(getId() == null){
            String hash = "" + this.getName();
            this.setId(Long.valueOf(EncryptionUtil.encrypt(hash).hashCode()));
        }
    }

    public Nationality(String iso, String name, String patronym, String iso3, int numCode) {
        this.iso = iso;
        this.name = name;
        this.patronym = patronym;
        this.iso3 = iso3;
        this.numCode = numCode;
    }

    public String getIso() {
        return iso;
    }

    public void setIso(String iso) {
        this.iso = iso;
    }

    public String getIso3() {
        return iso3;
    }

    public void setIso3(String iso3) {
        this.iso3 = iso3;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPatronym() {
        return patronym;
    }

    public void setPatronym(String patronym) {
        this.patronym = patronym;
    }

    public int getNumCode() {
        return numCode;
    }

    public void setNumCode(int numCode) {
        this.numCode = numCode;
    }
}
